﻿@model Apps.Models.WMS.WMS_Inventory_DModel
@using Apps.Web.Core;
@using Apps.Common;
@using Apps.Models.WMS;
@using Apps.Web;
@using Apps.Locale;
@using Apps.Models.Sys;
@{
    ViewBag.Title = "创建";
    Layout = "~/Views/Shared/_Index_LayoutEdit.cshtml";
    List<permModel> perm = null;
}

<script type="text/javascript">
$(function () {
    $('#List').datagrid({
        url: '@Url.Action("GetInvList", "InvInfo")?type="datagrid"',
        width:SetGridWidthSub(10),
        methord: 'post',
        height: SetGridHeightSub(45),
        fitColumns: true,
        sortName: 'InvCode',
        sortOrder: 'desc',
        idField: 'Id',
        striped: true, //奇偶行是否区分
        columns: [[
            {
                field: 'ck', checkbox: true,
            },
            { field: 'Id', title: '库房ID', width: 80, hidden: true },
            { field: 'InvCode', title: '库房编码', width: 80,sortable:true },
            { field: 'InvName', title: '库房名称', width: 80,sortable:true },
        ]]
    });

    $("#btnSave").click(function () {
        if ($("form").valid()) {
            var $dg = $('#List');
            var rows = $dg.datagrid('getChecked');
            //将所选中的行转换成json字符串，并保存到inserted隐藏输入框中。
            $("#inserted").val(JSON.stringify(rows));
            if (rows.length)
            {
                $.ajax({
                    url: "@Url.Action("Create")",
                    type: "Post",
                    data: { headId: $("#HeadId").val(), invList: $("#inserted").val() },
                    dataType: "json",
                    success: function (data)
                    {
                        if (data.type == 1)
                        {
                            window.parent.frameReturnByMes(data.message);
                            window.parent.frameReturnByReload(true);
                            window.parent.frameReturnByClose()
                        }
                        else
                        {
                            window.parent.frameReturnByMes(data.message);
                        }
                    }
                });
            }
            else
            {
                $.messageBox5s('提示', "没有数据需要保存！");
            }
        }
        return false;
    });

    $("#btnReturn").click(function () {
         window.parent.frameReturnByClose();
    });
});
function frameReturnByClose() {
$("#modalwindow").window('close');
}
function frameReturnByMes(mes) {
$.messageBox5s(Lang.Tip, mes);
}
</script>
<div id="modalwindow" class="easyui-window" style="width:800px; height:400px;" data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>
<div class="mvctool bgb">
    @Html.ToolButton("btnSave", "fa fa-save", Resource.Save, ref perm, "Save", true)
    @Html.ToolButton("btnReturn", "fa fa-reply", Resource.Reply, false)
</div>
@using (Html.BeginForm())
{
    @Html.HiddenFor(model => model.Id, new { @Value = 0 })
    <input id="CreateTime" type="hidden" name="CreateTime" value="2000-1-1" />
    @Html.HiddenFor(model => model.HeadId)
    <input id="inserted" type="hidden" name="inserted" value="" />
    <table class="formtable">
        <tbody>
            <tr>
                <td>
                    <table id="List"></table>
                </td>
            </tr>
        </tbody>
    </table>
}

